#!/usr/bin/python
# -*- coding: UTF-8 -*-
import sys
import os

cur_path =os.path.abspath(os.path.join(os.path.dirname('__file__'), os.path.pardir))
sys.path.append(cur_path)

from kazoo.client import KazooClient
from psm_conf import *


offline=("172.21.39.1","172.21.39.2", "172.21.39.3", "172.21.39.4", "172.21.39.5","172.21.39.6", "172.21.39.8", "172.21.39.10", "172.21.39.12", "172.21.39.14" )
 
realtime=("172.21.34.88", "172.21.34.44" ,"172.21.34.178", "172.21.34.20" ,"172.21.34.40","172.21.34.60" "172.21.34.115", "172.21.34.24" ,"172.21.34.73" ,"172.21.34.143")

online=("172.21.34.192", "172.21.34.159" ,"172.21.34.126" ,"172.21.34.82" ,"172.21.34.199","172.21.34.98", "172.21.34.59", "172.21.34.180", "172.21.34.166", "172.21.34.105")



zkc = KazooClient(hosts=ZK_URL, timeout=100)
zkc.start()

i=1

while i<len(sys.argv):
    machine_type=""
    if sys.argv[i] in realtime:
        machine_type="realtime"
    elif sys.argv[i] in offline:
        machine_type="offline"
    elif sys.argv[i] in online:
        machine_type="online"
    if machine_type == "":
        continue
    psm_path=ZK_PATH+"/"+machine_type+"/"+sys.argv[i]+":"+str(PORT_PSM_WORKER)
    if not zkc.exists(psm_path):
        print("no "+psm_path)
    else: 
        print("Delete psm_path path: "+psm_path)
        zkc.delete(psm_path, recursive=True)
    i+=1

